<meta charset="UTF-8">
<?php
include_once("../functions/db_manipulate.php");

if (!init()) {
  redirect("?action=login");
}
connectDB();

startTransaction();

$timeStamp = getLocalTimeStamp();

$delUserRes = mysql_query("INSERT INTO deleteusers (userid, date) VALUES ('1', '" . mysql_real_escape_string(f_Date($timeStamp)) . "')") or die(mysql_error());

$visResultSet = mysql_query("UPDATE users SET visible = '0' WHERE id='" . $_SESSION['id'] . "'") or die(mysql_error());

$initiatorAction = \controller\ControllerUtil::getEncodedActionFromUrlWithParameters($_SERVER['HTTP_REFERER']);

if ($delUserRes && $visResultSet) {
  commitTransaction();
  redirect("?action=msg&header=header.user.delete.success&body=body.user.delete.success&view=" . $initiatorAction);
} else {
  rollbackTransaction();
  redirect("?action=msg&header=header.user.delete.failed&body=body.user.delete.failed&view=" . $initiatorAction);
}

?>

